/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author corneliugosa
 */
@Entity
@Table(name = "catalogue")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Catalogue.findAll", query = "SELECT c FROM Catalogue c")})
public class Catalogue implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "grade")
    private float grade;
    @JoinColumn(name = "id_subject_matter", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private SubjectMatter idSubjectMatter;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "catalogue")
    private List<LinkCatalogue> linkCatalogueList;

    public Catalogue() {
    }

    public Catalogue(Integer id) {
        this.id = id;
    }

    public Catalogue(Integer id, float grade) {
        this.id = id;
        this.grade = grade;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public float getGrade() {
        return grade;
    }

    public void setGrade(float grade) {
        this.grade = grade;
    }

    public SubjectMatter getIdSubjectMatter() {
        return idSubjectMatter;
    }

    public void setIdSubjectMatter(SubjectMatter idSubjectMatter) {
        this.idSubjectMatter = idSubjectMatter;
    }

    @XmlTransient
    public List<LinkCatalogue> getLinkCatalogueList() {
        return linkCatalogueList;
    }

    public void setLinkCatalogueList(List<LinkCatalogue> linkCatalogueList) {
        this.linkCatalogueList = linkCatalogueList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Catalogue)) {
            return false;
        }
        Catalogue other = (Catalogue) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Catalogue[ id=" + id + " ]";
    }
    
}
